const path = require("path");

function resolve(dir) {
  return path.join(__dirname, "..", dir);
}

module.exports = async ({ config }) => {
  config.resolve.extensions.concat([".js", ".json", ".vue", ".less"]);
  config.resolve.alias = {
    vue$: "vue/dist/vue.esm.js",
    "@": resolve("src"),
    "@styles": resolve("src/styles"),
    "@comp": resolve("src/components")
  };
  config.module.rules.push({
    test: /\.(css|less)$/,
    use: ["vue-style-loader", "css-loader", "postcss-loader", "less-loader"],
  });
  config.module.rules.push({
    test: /\.story\.js?$/,
    loaders: [require.resolve("@storybook/addon-storysource/loader")],
    enforce: "pre",
  });
  return config;
};
